/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Donnees;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author mizho
 */
@Entity
@Table(name = "td")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Td.findAll", query = "SELECT t FROM Td t"),
    @NamedQuery(name = "Td.findByIdtd", query = "SELECT t FROM Td t WHERE t.idtd = :idtd"),
    @NamedQuery(name = "Td.findByTitre", query = "SELECT t FROM Td t WHERE t.titre = :titre"),
    @NamedQuery(name = "Td.findByIntroduction", query = "SELECT t FROM Td t WHERE t.introduction = :introduction")})
public class Td implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "idtd")
    private String idtd;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "titre")
    private String titre;
    @Size(max = 10000)
    @Column(name = "introduction")
    private String introduction;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "td")
    private Collection<TdUe> tdUeCollection;
    @JoinColumn(name = "idauteur", referencedColumnName = "idutilisateur")
    @ManyToOne(optional = false)
    private Utilisateur idauteur;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "td")
    private Collection<TdExo> tdExoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "td")
    private Collection<Acces> accesCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "td")
    private Collection<Commentaire> commentaireCollection;

    public Td() {
    }

    public Td(String idtd) {
        this.idtd = idtd;
    }

    public Td(String idtd, String titre) {
        this.idtd = idtd;
        this.titre = titre;
    }

    public String getIdtd() {
        return idtd;
    }

    public void setIdtd(String idtd) {
        this.idtd = idtd;
    }

    public String getTitre() {
        return titre;
    }

    public void setTitre(String titre) {
        this.titre = titre;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }

    @XmlTransient
    public Collection<TdUe> getTdUeCollection() {
        return tdUeCollection;
    }

    public void setTdUeCollection(Collection<TdUe> tdUeCollection) {
        this.tdUeCollection = tdUeCollection;
    }

    public Utilisateur getIdauteur() {
        return idauteur;
    }

    public void setIdauteur(Utilisateur idauteur) {
        this.idauteur = idauteur;
    }

    @XmlTransient
    public Collection<TdExo> getTdExoCollection() {
        return tdExoCollection;
    }

    public void setTdExoCollection(Collection<TdExo> tdExoCollection) {
        this.tdExoCollection = tdExoCollection;
    }

    @XmlTransient
    public Collection<Acces> getAccesCollection() {
        return accesCollection;
    }

    public void setAccesCollection(Collection<Acces> accesCollection) {
        this.accesCollection = accesCollection;
    }

    @XmlTransient
    public Collection<Commentaire> getCommentaireCollection() {
        return commentaireCollection;
    }

    public void setCommentaireCollection(Collection<Commentaire> commentaireCollection) {
        this.commentaireCollection = commentaireCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idtd != null ? idtd.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Td)) {
            return false;
        }
        Td other = (Td) object;
        if ((this.idtd == null && other.idtd != null) || (this.idtd != null && !this.idtd.equals(other.idtd))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Donnees.Td[ idtd=" + idtd + " ]";
    }
    
}
